home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 June / MacFormat 25.iso / Shareware City / Developers / OutOfPhase1.1 Source / OutOfPhase Folder / InstrumentStructure.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-12-29  |  4.6 KB  |  141 lines  |  [TEXT/KAHL]

  1. /* InstrumentStructure.c */
  2. /*****************************************************************************/
  3. /*                                                                           */
  4. /*    Out Of Phase:  Digital Music Synthesis on General Purpose Computers    */
  5. /*    Copyright (C) 1994  Thomas R. Lawrence                                 */
  6. /*                                                                           */
  7. /*    This program is free software; you can redistribute it and/or modify   */
  8. /*    it under the terms of the GNU General Public License as published by   */
  9. /*    the Free Software Foundation; either version 2 of the License, or      */
  10. /*    (at your option) any later version.                                    */
  11. /*                                                                           */
  12. /*    This program is distributed in the hope that it will be useful,        */
  13. /*    but WITHOUT ANY WARRANTY; without even the implied warranty of         */
  14. /*    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          */
  15. /*    GNU General Public License for more details.                           */
  16. /*                                                                           */
  17. /*    You should have received a copy of the GNU General Public License      */
  18. /*    along with this program; if not, write to the Free Software            */
  19. /*    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.              */
  20. /*                                                                           */
  21. /*    Thomas R. Lawrence can be reached at tomlaw@world.std.com.             */
  22. /*                                                                           */
  23. /*****************************************************************************/
  24.  
  25. #include "MiscInfo.h"
  26. #include "Audit.h"
  27. #include "Debug.h"
  28. #include "Definitions.h"
  29.  
  30. #include "InstrumentStructure.h"
  31. #include "Memory.h"
  32. #include "LFOListSpecifier.h"
  33. #include "OscillatorListSpecifier.h"
  34. #include "EffectSpecList.h"
  35.  
  36.  
  37. struct InstrumentRec
  38.     {
  39.         /* this is the overall loudness factor for the instrument, which can be used */
  40.         /* to differentiate "loud" on a quite instrument vs. "loud" on a loud instrument. */
  41.         InstrNumberType                            OverallLoudness;
  42.  
  43.         /* list of LFO operators on the frequency */
  44.         struct LFOListSpecRec*            FrequencyLFOList;
  45.  
  46.         /* list of oscillators */
  47.         struct OscillatorListRec*        OscillatorList;
  48.  
  49.         /* list of track effects */
  50.         struct EffectSpecListRec*        EffectSpecList;
  51.     };
  52.  
  53.  
  54. /* create a new instrument specification record */
  55. InstrumentRec*                        NewInstrumentSpecifier(void)
  56.     {
  57.         InstrumentRec*            Instr;
  58.  
  59.         Instr = (InstrumentRec*)AllocPtrCanFail(sizeof(InstrumentRec),"InstrumentRec");
  60.         if (Instr == NIL)
  61.             {
  62.              FailurePoint1:
  63.                 return NIL;
  64.             }
  65.         Instr->OverallLoudness = 1;
  66.         Instr->FrequencyLFOList = NewLFOListSpecifier();
  67.         if (Instr->FrequencyLFOList == NIL)
  68.             {
  69.              FailurePoint2:
  70.                 ReleasePtr((char*)Instr);
  71.                 goto FailurePoint1;
  72.             }
  73.         Instr->OscillatorList = NewOscillatorListSpecifier();
  74.         if (Instr->OscillatorList == NIL)
  75.             {
  76.              FailurePoint3:
  77.                 DisposeLFOListSpecifier(Instr->FrequencyLFOList);
  78.                 goto FailurePoint2;
  79.             }
  80.         Instr->EffectSpecList = NewEffectSpecList();
  81.         if (Instr->EffectSpecList == NIL)
  82.             {
  83.              FailurePoint4:
  84.                 DisposeOscillatorListSpecifier(Instr->OscillatorList);
  85.                 goto FailurePoint3;
  86.             }
  87.         return Instr;
  88.     }
  89.  
  90.  
  91. /* dispose of the instrument specification record */
  92. void                                            DisposeInstrumentSpecification(InstrumentRec* Instr)
  93.     {
  94.         CheckPtrExistence(Instr);
  95.         DisposeEffectSpecList(Instr->EffectSpecList);
  96.         DisposeOscillatorListSpecifier(Instr->OscillatorList);
  97.         DisposeLFOListSpecifier(Instr->FrequencyLFOList);
  98.         ReleasePtr((char*)Instr);
  99.     }
  100.  
  101.  
  102. /* get the overall loudness of the instrument */
  103. InstrNumberType                        GetInstrumentOverallLoudness(InstrumentRec* Instr)
  104.     {
  105.         CheckPtrExistence(Instr);
  106.         return Instr->OverallLoudness;
  107.     }
  108.  
  109.  
  110. /* put a new value for overall loudness */
  111. void                                            InstrumentSetOverallLoudness(InstrumentRec* Instr,
  112.                                                         double NewLoudness)
  113.     {
  114.         CheckPtrExistence(Instr);
  115.         Instr->OverallLoudness = NewLoudness;
  116.     }
  117.  
  118.  
  119. /* get the instrument's frequency LFO list */
  120. struct LFOListSpecRec*        GetInstrumentFrequencyLFOList(InstrumentRec* Instr)
  121.     {
  122.         CheckPtrExistence(Instr);
  123.         return Instr->FrequencyLFOList;
  124.     }
  125.  
  126.  
  127. /* get the instrument's oscillator list */
  128. struct OscillatorListRec*    GetInstrumentOscillatorList(InstrumentRec* Instr)
  129.     {
  130.         CheckPtrExistence(Instr);
  131.         return Instr->OscillatorList;
  132.     }
  133.  
  134.  
  135. /* get the effect specifier list */
  136. struct EffectSpecListRec*    GetInstrumentEffectSpecList(InstrumentRec* Instr)
  137.     {
  138.         CheckPtrExistence(Instr);
  139.         return Instr->EffectSpecList;
  140.     }
  141.